package cn.tedu.oopstatic;

/**
 * @Author 金帮嘉诚
 * @Date 2021-06-09 周三 16:44
 */
/*本类用于测试静态的调用关系*/
public class TestStatic2 {
    public static void main(String[] args) {
        //测试代码的方法1.加打印语句2.Debug
        //

    }
}
/**测试方法：分类讨论 静态/普通 资源能否调用 静态/普通 资源
 * 总结：静态资源只能调用静态资源，普通资源可调用静态和普通资源
 * 静态的main里面调用非静态方法 需要new（实例化）对象，通过对象调用
 * */

//1.
class Teacher{
    //2.普通资源

    //2.1普通属性
    String name;
    //2.2normal method
    public void teach(){
        /*1.普通资源能否调用静态资源？能*/
        System.out.println(name);//Normal sources are able to call static field
        eat();//Normal sources are able to call static method

        System.out.println("Teaching~~~~");
    }
    //3.static sources
    //3.1static field
    static int age;
    //3.2static method
    public static void eat(){
        /*2.静态资源能否调用普通资源？不能*/
        //System.out.println(name);//Non-static field 'name' cannot be referenced from a static context
        //teach();//Non-static method 'teach()' cannot be referenced from a static context
        System.out.println("扶我起来 我还能吃....");
    }
    public static void sleep(){
        /*静态资源能否调用静态资源？能*/
        System.out.println(age);//Static field can be referenced from a static context
        eat();//Static method can be referenced from a static context
        System.out.println("Drink Xxx when tired and sleepy");
    }
}
